package com.project_task.controller;

import com.project_task.dto.ProjectDTO;
import com.project_task.dto.ProjectPageQueryDTO;
import com.project_task.result.PageResult;
import com.project_task.result.Result;
import com.project_task.service.ProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/project")
@Api(tags = "项目管理相关接口")
@Slf4j
public class ProjectController {

    @Autowired
    private ProjectService projectService;

    @PostMapping("/save")
    @ApiOperation("创建项目")
    public Result save(@RequestBody ProjectDTO projectDTO){
        log.info("新增项目：{}", projectDTO);
        projectService.save(projectDTO);
        return Result.success();
    }

    @GetMapping("/page")
    @ApiOperation("项目分页查询")
    public Result<PageResult> page(ProjectPageQueryDTO projectPageQueryDTO){
        log.info("项目分页查询:{}", projectPageQueryDTO);
        PageResult pageResult = projectService.pageQuery(projectPageQueryDTO);
        return Result.success(pageResult);
    }

}
